<?php

require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'SocialProvider.php');
class TwitterProvider extends SocialProvider
{
    public $type = 'twitter';
    
    public function authenticate()
    {
        //TODO: Get the id of the current user (must be an int)
        $userId = 0;
        $consumerKey = $this->getConsumerKey($userId);
        try
        {
            // Request parameters are oauth_token, consumer_key and usr_id.
            if (isset($_GET['oauth_token']))
            {
                $oauthToken = $_GET['oauth_token'];
                return $this->requestAccessToken($consumerKey, $oauthToken, $userId, $_GET);
            }
            else
            {
                $this->requestToken($consumerKey, $userId);
            }
        }
        catch(OAuthException2 $e)
        {
            Yii::log($e->getMessage(), CLogger::LEVEL_ERROR, 'SocialProvider');
        }
        return false;
    }
}